/**
 * Created by vasil on 11/5/14.
 */
angular.module('MyApp')
    .factory('posts', function() {
        var posts = [
            {
                time: new Date(), text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a ' +
                'galley of type and scrambled it to make a type specimen book. ' +
                'It has survived not only five centuries, but also the leap into ' +
                'electronic typesetting, remaining essentially unc'
            },
            {
                time: new Date(), text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a ' +
                'galley of type and scrambled it to make a type specimen book. ' +
                'It has survived not only five centuries, but also the leap into ' +
                'electronic typesetting, remaining essentially unc'
            },
            {
                time: new Date(), text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a ' +
                'galley of type and scrambled it to make a type specimen book. ' +
                'It has survived not only five centuries, but also the leap into ' +
                'electronic typesetting, remaining essentially unc'
            },
            {
                time: new Date(), text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a ' +
                'galley of type and scrambled it to make a type specimen book. ' +
                'It has survived not only five centuries, but also the leap into ' +
                'electronic typesetting, remaining essentially unc'
            }
        ];



        return {
            add : function (text) {
                posts.push({
                    time: new Date(),
                    text: text
                })
            },
            remove : function (index) {
                posts.splice(index, 1);
            },
            get: function (index) {
                return posts[index];
            },
            getAll: function() {
                return posts;
            }
        }
    })